<!DOCTYPE html>
<html lang="en-US" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>My Notebook</title>
    <meta name="description" content="Web Full Stack">
    <meta name="generator" content="VitePress v2.0.0-alpha.8">
    <link rel="preload stylesheet" href="/assets/style.BoEYU21q.css" as="style">
    <link rel="preload stylesheet" href="/vp-icons.css" as="style">
    
    <script type="module" src="/assets/app.B02vW-ec.js"></script>
    <link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/assets/chunks/theme.C-WtvMek.js">
    <link rel="modulepreload" href="/assets/chunks/framework.CBqoqC2Z.js">
    <link rel="modulepreload" href="/assets/server_linux_nfs.md.BWanbGvi.lean.js">
    <script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
    <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-6b0b2476><!--[--><!--]--><!--[--><span tabindex="-1" data-v-a0b1b6d8></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-a0b1b6d8>Skip to content</a><!--]--><!----><header class="VPNav" data-v-6b0b2476 data-v-4f4c5d52><div class="VPNavBar" data-v-4f4c5d52 data-v-51f57b10><div class="wrapper" data-v-51f57b10><div class="container" data-v-51f57b10><div class="title" data-v-51f57b10><div class="VPNavBarTitle has-sidebar" data-v-51f57b10 data-v-87dac50e><a class="title" href="/" data-v-87dac50e><!--[--><!--]--><!--[--><img class="VPImage logo" src="/logo.png" alt data-v-86ce8179><!--]--><span data-v-87dac50e>My Notebook</span><!--[--><!--]--></a></div></div><div class="content" data-v-51f57b10><div class="content-body" data-v-51f57b10><!--[--><!--]--><div class="VPNavBarSearch search" data-v-51f57b10><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-51f57b10 data-v-0273b940><span id="main-nav-aria-label" class="visually-hidden" data-v-0273b940> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/" tabindex="0" data-v-0273b940 data-v-d665effb><!--[--><span data-v-d665effb>Home</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/examples.html" tabindex="0" data-v-0273b940 data-v-d665effb><!--[--><span data-v-d665effb>Examples</span><!--]--></a><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-0273b940 data-v-dc6c2d40><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-dc6c2d40><span class="text" data-v-dc6c2d40><!----><span data-v-dc6c2d40>前端</span><span class="vpi-chevron-down text-icon" data-v-dc6c2d40></span></span></button><div class="menu" data-v-dc6c2d40><div class="VPMenu" data-v-dc6c2d40 data-v-2bc412f4><div class="items" data-v-2bc412f4><!--[--><!--[--><div class="VPMenuLink" data-v-2bc412f4 data-v-1af4d5df><a class="VPLink link" href="/web/websocket/Reverb-protocol.html" data-v-1af4d5df><!--[--><span data-v-1af4d5df>WebSocket</span><!--]--></a></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-0273b940 data-v-dc6c2d40><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-dc6c2d40><span class="text" data-v-dc6c2d40><!----><span data-v-dc6c2d40>后端</span><span class="vpi-chevron-down text-icon" data-v-dc6c2d40></span></span></button><div class="menu" data-v-dc6c2d40><div class="VPMenu" data-v-dc6c2d40 data-v-2bc412f4><div class="items" data-v-2bc412f4><!--[--><!--[--><div class="VPMenuLink" data-v-2bc412f4 data-v-1af4d5df><a class="VPLink link" href="/server/linux.html" data-v-1af4d5df><!--[--><span data-v-1af4d5df>Linux</span><!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-2bc412f4 data-v-1af4d5df><a class="VPLink link" href="/server/php.html" data-v-1af4d5df><!--[--><span data-v-1af4d5df>PHP</span><!--]--></a></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-0273b940 data-v-dc6c2d40><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-dc6c2d40><span class="text" data-v-dc6c2d40><!----><span data-v-dc6c2d40>中间件</span><span class="vpi-chevron-down text-icon" data-v-dc6c2d40></span></span></button><div class="menu" data-v-dc6c2d40><div class="VPMenu" data-v-dc6c2d40 data-v-2bc412f4><div class="items" data-v-2bc412f4><!--[--><!--[--><div class="VPMenuLink" data-v-2bc412f4 data-v-1af4d5df><a class="VPLink link" href="/middleware/nginx.html" data-v-1af4d5df><!--[--><span data-v-1af4d5df>Nginx</span><!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-2bc412f4 data-v-1af4d5df><a class="VPLink link" href="/middleware/docker.html" data-v-1af4d5df><!--[--><span data-v-1af4d5df>Docker</span><!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-2bc412f4 data-v-1af4d5df><a class="VPLink link" href="/middleware/mysql.html" data-v-1af4d5df><!--[--><span data-v-1af4d5df>MySQL</span><!--]--></a></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-0273b940 data-v-dc6c2d40><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-dc6c2d40><span class="text" data-v-dc6c2d40><!----><span data-v-dc6c2d40>工具</span><span class="vpi-chevron-down text-icon" data-v-dc6c2d40></span></span></button><div class="menu" data-v-dc6c2d40><div class="VPMenu" data-v-dc6c2d40 data-v-2bc412f4><div class="items" data-v-2bc412f4><!--[--><!--[--><div class="VPMenuLink" data-v-2bc412f4 data-v-1af4d5df><a class="VPLink link" href="/tools/git.html" data-v-1af4d5df><!--[--><span data-v-1af4d5df>Git</span><!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-2bc412f4 data-v-1af4d5df><a class="VPLink link" href="/tools/acme.sh.html" data-v-1af4d5df><!--[--><span data-v-1af4d5df>SSL</span><!--]--></a></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-51f57b10 data-v-4659d581><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-4659d581 data-v-44089c99 data-v-fef47d35><span class="check" data-v-fef47d35><span class="icon" data-v-fef47d35><!--[--><span class="vpi-sun sun" data-v-44089c99></span><span class="vpi-moon moon" data-v-44089c99></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-51f57b10 data-v-6f4b4b54 data-v-aa6c3ac1><!--[--><a class="VPSocialLink no-icon" href="https://gitee.com/hutaoseven/note" aria-label="gitee" target="_blank" rel="noopener" data-v-aa6c3ac1 data-v-93b655d1><span class="vpi-social-gitee"></span></a><a class="VPSocialLink no-icon" href="https://github.com/hutaoseven" aria-label="github" target="_blank" rel="noopener" data-v-aa6c3ac1 data-v-93b655d1><span class="vpi-social-github"></span></a><a class="VPSocialLink no-icon" href="https://vitepress.dev/zh" aria-label="vitepress" target="_blank" rel="noopener" data-v-aa6c3ac1 data-v-93b655d1><span class="vpi-social-vitepress"></span></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-51f57b10 data-v-f3922e92 data-v-dc6c2d40><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-dc6c2d40><span class="vpi-more-horizontal icon" data-v-dc6c2d40></span></button><div class="menu" data-v-dc6c2d40><div class="VPMenu" data-v-dc6c2d40 data-v-2bc412f4><!----><!--[--><!--[--><!----><div class="group" data-v-f3922e92><div class="item appearance" data-v-f3922e92><p class="label" data-v-f3922e92>Appearance</p><div class="appearance-action" data-v-f3922e92><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-f3922e92 data-v-44089c99 data-v-fef47d35><span class="check" data-v-fef47d35><span class="icon" data-v-fef47d35><!--[--><span class="vpi-sun sun" data-v-44089c99></span><span class="vpi-moon moon" data-v-44089c99></span><!--]--></span></span></button></div></div></div><div class="group" data-v-f3922e92><div class="item social-links" data-v-f3922e92><div class="VPSocialLinks social-links-list" data-v-f3922e92 data-v-aa6c3ac1><!--[--><a class="VPSocialLink no-icon" href="https://gitee.com/hutaoseven/note" aria-label="gitee" target="_blank" rel="noopener" data-v-aa6c3ac1 data-v-93b655d1><span class="vpi-social-gitee"></span></a><a class="VPSocialLink no-icon" href="https://github.com/hutaoseven" aria-label="github" target="_blank" rel="noopener" data-v-aa6c3ac1 data-v-93b655d1><span class="vpi-social-github"></span></a><a class="VPSocialLink no-icon" href="https://vitepress.dev/zh" aria-label="vitepress" target="_blank" rel="noopener" data-v-aa6c3ac1 data-v-93b655d1><span class="vpi-social-vitepress"></span></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-51f57b10 data-v-0b6d9ee1><span class="container" data-v-0b6d9ee1><span class="top" data-v-0b6d9ee1></span><span class="middle" data-v-0b6d9ee1></span><span class="bottom" data-v-0b6d9ee1></span></span></button></div></div></div></div><div class="divider" data-v-51f57b10><div class="divider-line" data-v-51f57b10></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-6b0b2476 data-v-b1290d98><div class="container" data-v-b1290d98><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-b1290d98><span class="vpi-align-left menu-icon" data-v-b1290d98></span><span class="menu-text" data-v-b1290d98>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-b1290d98 data-v-a9af13e0><button data-v-a9af13e0>Top</button><!----></div></div></div><aside class="VPSidebar" data-v-6b0b2476 data-v-5ff33f85><div class="curtain" data-v-5ff33f85></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-5ff33f85><span class="visually-hidden" id="sidebar-aria-label" data-v-5ff33f85> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-4d4b1274><section class="VPSidebarItem level-0" data-v-4d4b1274 data-v-9b050556><!----><div class="items" data-v-9b050556><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b050556 data-v-9b050556><div class="item" data-v-9b050556><div class="indicator" data-v-9b050556></div><a class="VPLink link link" href="/server/linux/rsync.html" data-v-9b050556><!--[--><p class="text" data-v-9b050556>Rsync</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-6b0b2476 data-v-e2f7c2ee><div class="VPDoc has-sidebar has-aside" data-v-e2f7c2ee data-v-0ce405a1><!--[--><!--]--><div class="container" data-v-0ce405a1><div class="aside" data-v-0ce405a1><div class="aside-curtain" data-v-0ce405a1></div><div class="aside-container" data-v-0ce405a1><div class="aside-content" data-v-0ce405a1><div class="VPDocAside" data-v-0ce405a1 data-v-09f6f51d><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-09f6f51d data-v-9067d3f4><div class="content" data-v-9067d3f4><div class="outline-marker" data-v-9067d3f4></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-9067d3f4>On this page</div><ul class="VPDocOutlineItem root" data-v-9067d3f4 data-v-8eb5c1fb><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-09f6f51d></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-0ce405a1><div class="content-container" data-v-0ce405a1><!--[--><!--]--><main class="main" data-v-0ce405a1><div style="position:relative;" class="vp-doc _server_linux_nfs" data-v-0ce405a1><div><p>在阿里云ECS（Elastic Compute Service）实例之间进行内网文件共享，可以通过以下几种方式实现。由于ECS实例之间在同一个VPC（Virtual Private Cloud）内可以通过内网IP直接通信，因此可以利用内网带宽进行高效的文件共享。</p><hr><h3 id="_1-使用-nfs-network-file-system" tabindex="-1">1. <strong>使用 NFS（Network File System）</strong> <a class="header-anchor" href="#_1-使用-nfs-network-file-system" aria-label="Permalink to “1. 使用 NFS（Network File System）”">​</a></h3><p>NFS 是一种常用的文件共享协议，适合在 Linux 系统之间共享文件。</p><p><strong>步骤：</strong></p><ol><li><p><strong>在服务端（共享文件的ECS实例）安装 NFS 服务：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nfs-kernel-server</span></span></code></pre></div></li><li><p><strong>配置共享目录：</strong> 编辑 <code>/etc/exports</code> 文件，添加共享目录配置：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">/path/to/shared/folder</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> client_ip</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rw,sync,no_subtree_check</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><p>例如：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">/data</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 172.16.0.0/16</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rw,sync,no_subtree_check</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></li><li><p><strong>重启 NFS 服务：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> restart</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nfs-kernel-server</span></span></code></pre></div></li><li><p><strong>在客户端（访问共享文件的ECS实例）安装 NFS 客户端：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nfs-common</span></span></code></pre></div></li><li><p><strong>挂载共享目录：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mount</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -t</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> server_ip:/path/to/shared/folder</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /local/mount/point</span></span></code></pre></div><p>例如：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mount</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -t</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 172.16.0.1:/data</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/nfs</span></span></code></pre></div></li></ol><hr><h3 id="_2-使用-samba" tabindex="-1">2. <strong>使用 Samba</strong> <a class="header-anchor" href="#_2-使用-samba" aria-label="Permalink to “2. 使用 Samba”">​</a></h3><p>Samba 是一种支持 Windows 和 Linux 系统之间文件共享的协议，适合跨平台共享。</p><p><strong>步骤：</strong></p><ol><li><p><strong>在服务端安装 Samba：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> samba</span></span></code></pre></div></li><li><p><strong>配置 Samba：</strong> 编辑 <code>/etc/samba/smb.conf</code> 文件，添加共享目录配置：</p><div class="language-ini"><button title="Copy Code" class="copy"></button><span class="lang">ini</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">[shared]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">path</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> = /path/to/shared/folder</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">writable</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> = yes</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">browsable</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> = yes</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">valid </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">users</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> = username</span></span></code></pre></div></li><li><p><strong>设置 Samba 用户密码：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> smbpasswd</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -a</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> username</span></span></code></pre></div></li><li><p><strong>重启 Samba 服务：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> restart</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> smbd</span></span></code></pre></div></li><li><p><strong>在客户端访问共享目录：</strong></p><ul><li><p>在 Linux 上使用 <code>cifs-utils</code> 挂载：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cifs-utils</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mount</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -t</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cifs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> //server_ip/shared</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /local/mount/point</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> username=username</span></span></code></pre></div></li><li><p>在 Windows 上通过文件资源管理器访问：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span>\\server_ip\shared</span></span></code></pre></div></li></ul></li></ol><hr><h3 id="_3-使用-rsync-同步文件" tabindex="-1">3. <strong>使用 Rsync 同步文件</strong> <a class="header-anchor" href="#_3-使用-rsync-同步文件" aria-label="Permalink to “3. 使用 Rsync 同步文件”">​</a></h3><p>Rsync 是一种高效的文件同步工具，适合定期同步文件。</p><p><strong>步骤：</strong></p><ol><li><p><strong>在服务端和客户端安装 Rsync：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> rsync</span></span></code></pre></div></li><li><p><strong>从客户端同步文件：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rsync</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -avz</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /path/to/local/folder</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> username@server_ip:/path/to/remote/folder</span></span></code></pre></div></li><li><p><strong>从服务端拉取文件：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rsync</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -avz</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> username@server_ip:/path/to/remote/folder</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /path/to/local/folder</span></span></code></pre></div></li></ol><hr><h3 id="_4-使用-scp-或-sftp-传输文件" tabindex="-1">4. <strong>使用 SCP 或 SFTP 传输文件</strong> <a class="header-anchor" href="#_4-使用-scp-或-sftp-传输文件" aria-label="Permalink to “4. 使用 SCP 或 SFTP 传输文件”">​</a></h3><p>SCP 和 SFTP 是基于 SSH 的文件传输工具，适合一次性文件传输。</p><p><strong>步骤：</strong></p><ol><li><p><strong>使用 SCP 传输文件：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">scp</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /path/to/local/file</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> username@server_ip:/path/to/remote/folder</span></span></code></pre></div></li><li><p><strong>使用 SFTP 管理文件：</strong></p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sftp</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> username@server_ip</span></span></code></pre></div></li></ol><hr><h3 id="_5-使用阿里云-nas-文件存储" tabindex="-1">5. <strong>使用阿里云 NAS（文件存储）</strong> <a class="header-anchor" href="#_5-使用阿里云-nas-文件存储" aria-label="Permalink to “5. 使用阿里云 NAS（文件存储）”">​</a></h3><p>阿里云 NAS（Network Attached Storage）是一种高性能、可扩展的文件存储服务，适合多台 ECS 实例共享文件。</p><p><strong>步骤：</strong></p><ol><li><strong>创建 NAS 文件系统：</strong><ul><li>登录阿里云控制台，进入 NAS 服务。</li><li>创建一个文件系统，并挂载到 VPC 中。</li></ul></li><li><strong>在 ECS 实例上挂载 NAS：</strong><ul><li><p>安装 NFS 客户端：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nfs-common</span></span></code></pre></div></li><li><p>挂载 NAS 文件系统：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mount</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -t</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nas_file_system_id.region.nas.aliyuncs.com:/</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /local/mount/point</span></span></code></pre></div></li></ul></li></ol><hr><h3 id="_6-使用阿里云-oss-对象存储" tabindex="-1">6. <strong>使用阿里云 OSS（对象存储）</strong> <a class="header-anchor" href="#_6-使用阿里云-oss-对象存储" aria-label="Permalink to “6. 使用阿里云 OSS（对象存储）”">​</a></h3><p>如果文件共享需求是跨地域或跨 VPC 的，可以使用阿里云 OSS（Object Storage Service）。</p><p><strong>步骤：</strong></p><ol><li><strong>创建 OSS Bucket：</strong><ul><li>登录阿里云控制台，进入 OSS 服务。</li><li>创建一个 Bucket。</li></ul></li><li><strong>使用 OSS 工具上传/下载文件：</strong><ul><li><p>安装 OSS 命令行工具：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> pip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> oss2</span></span></code></pre></div></li><li><p>上传文件：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ossutil</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cp</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /path/to/local/file</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> oss://bucket-name/path/to/remote/file</span></span></code></pre></div></li><li><p>下载文件：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ossutil</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cp</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> oss://bucket-name/path/to/remote/file</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /path/to/local/file</span></span></code></pre></div></li></ul></li></ol><hr><h3 id="总结" tabindex="-1">总结 <a class="header-anchor" href="#总结" aria-label="Permalink to “总结”">​</a></h3><ul><li><strong>NFS</strong>：适合 Linux 系统之间的文件共享。</li><li><strong>Samba</strong>：适合跨平台（Linux 和 Windows）文件共享。</li><li><strong>Rsync</strong>：适合定期同步文件。</li><li><strong>SCP/SFTP</strong>：适合一次性文件传输。</li><li><strong>阿里云 NAS</strong>：适合多台 ECS 实例共享文件，性能高。</li><li><strong>阿里云 OSS</strong>：适合跨地域或大规模文件存储和共享。</li></ul><p>根据你的具体需求选择合适的方式。如果文件共享需求频繁且规模较大，推荐使用阿里云 NAS 或 OSS。</p></div></div></main><footer class="VPDocFooter" data-v-0ce405a1 data-v-a8b82ce1><!--[--><!--]--><div class="edit-info" data-v-a8b82ce1><!----><div class="last-updated" data-v-a8b82ce1><p class="VPLastUpdated" data-v-a8b82ce1 data-v-9b597531>Last updated: <time datetime="2025-07-09T07:31:53.000Z" data-v-9b597531></time></p></div></div><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-a8b82ce1><span class="visually-hidden" id="doc-footer-aria-label" data-v-a8b82ce1>Pager</span><div class="pager" data-v-a8b82ce1><!----></div><div class="pager" data-v-a8b82ce1><a class="VPLink link pager-link next" href="/server/linux/rsync.html" data-v-a8b82ce1><!--[--><span class="desc" data-v-a8b82ce1>Next page</span><span class="title" data-v-a8b82ce1>Rsync</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-6b0b2476 data-v-5e9bdbcf><div class="container" data-v-5e9bdbcf><p class="message" data-v-5e9bdbcf>Released under the MIT License.</p><p class="copyright" data-v-5e9bdbcf>Copyright © 2015-present <a href="https://www.hutao.me">Seven</a></p></div></footer><!--[--><!--]--></div></div>
    <script>window.__VP_HASH_MAP__=JSON.parse("{\"examples_api-examples.md\":\"BVuUDC8u\",\"examples_index.md\":\"DRDP5V7T\",\"examples_markdown-examples.md\":\"CRI4GTF1\",\"index.md\":\"ht8CDx0T\",\"middleware_docker_index.md\":\"qjq2KNst\",\"middleware_index.md\":\"HBYKVdxd\",\"middleware_mysql_foreignkey.md\":\"BFJBb4J_\",\"middleware_mysql_index.md\":\"CT5BYJN5\",\"middleware_nginx_index.md\":\"COkUxaTh\",\"server_linux_index.md\":\"Bs5nX7hB\",\"server_linux_nfs.md\":\"BWanbGvi\",\"server_linux_rsync.md\":\"DB-FYsHZ\",\"server_php_debug.md\":\"723SyYGr\",\"server_php_ext.md\":\"Bw24_QTo\",\"server_php_index.md\":\"DVMhui_p\",\"tools_acme.sh.md\":\"DPG5WCVa\",\"tools_git_index.md\":\"CniIVJs6\",\"tools_git_worktree.md\":\"CiKoAIJv\",\"tools_index.md\":\"CckS_OJj\",\"web_index.md\":\"ISte9ZJM\",\"web_websocket_reverb-protocol.md\":\"stb4s5pV\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"My Notebook\",\"description\":\"Web Full Stack\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"logo\":\"/logo.png\",\"returnToTopLabel\":\"Top\",\"search\":{\"provider\":\"local\"},\"nav\":[{\"text\":\"Home\",\"link\":\"/\"},{\"text\":\"Examples\",\"link\":\"/examples\"},{\"text\":\"前端\",\"items\":[{\"text\":\"WebSocket\",\"link\":\"/web/websocket/Reverb-protocol\"}]},{\"text\":\"后端\",\"items\":[{\"text\":\"Linux\",\"link\":\"/server/linux\"},{\"text\":\"PHP\",\"link\":\"/server/php\"}]},{\"text\":\"中间件\",\"items\":[{\"text\":\"Nginx\",\"link\":\"/middleware/nginx\"},{\"text\":\"Docker\",\"link\":\"/middleware/docker\"},{\"text\":\"MySQL\",\"link\":\"/middleware/mysql\"}]},{\"text\":\"工具\",\"items\":[{\"text\":\"Git\",\"link\":\"/tools/git\"},{\"text\":\"SSL\",\"link\":\"/tools/acme.sh\"}]}],\"sidebar\":{\"/examples/\":{\"base\":\"/examples/\",\"items\":[{\"text\":\"Markdown Examples\",\"link\":\"/markdown-examples\"},{\"text\":\"Runtime API Examples\",\"link\":\"/api-examples\"}],\"collapsed\":true},\"/server/linux/\":{\"base\":\"/server/linux/\",\"items\":[{\"text\":\"Rsync\",\"link\":\"/rsync\"}],\"collapsed\":true},\"/server/php/\":{\"base\":\"/server/php/\",\"items\":[{\"text\":\"安装扩展\",\"link\":\"/ext\"},{\"text\":\"Xdebug调试\",\"link\":\"/debug\"}],\"collapsed\":true},\"/tools/git/\":{\"base\":\"/tools/git/\",\"items\":[{\"text\":\"worktree\",\"link\":\"/worktree\"}],\"collapsed\":true},\"/middleware/mysql\":{\"base\":\"/middleware/mysql\",\"items\":[{\"text\":\"ForeignKey\",\"link\":\"/foreignKey\"}],\"collapsed\":true}},\"socialLinks\":[{\"icon\":\"gitee\",\"link\":\"https://gitee.com/hutaoseven/note\"},{\"icon\":\"github\",\"link\":\"https://github.com/hutaoseven\"},{\"icon\":\"vitepress\",\"link\":\"https://vitepress.dev/zh\"}],\"footer\":{\"message\":\"Released under the MIT License.\",\"copyright\":\"Copyright © 2015-present <a href=\\\"https://www.hutao.me\\\">Seven</a>\"}},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false,\"additionalConfig\":{}}");</script>
    
  </body>
</html>